// 引入axios
import axios from 'axios'
// 设置基地址
axios.defaults.baseURL = "http://120.25.126.174:8160/";
// 设置请求拦截器
axios.interceptors.request.use(config =>{
    // 设置请求头，为token赋值token令牌
    config.headers.token = window.sessionStorage.getItem("token");
    // 在最后必须return config
    return config;
})
//获取邮箱验证码
const getEmailVerify = (email)=>axios.get(`educenter/email/send/${email}`);
//邮箱登录接口
const emailLogin = (emailInfo)=>axios.post("/educenter/email/login",emailInfo);
// 获取用户ID
const getMemberInfo = ()=>axios.get("/educenter/member/getMemberInfo");
// 获取用户笔记
const getNote = (fatherid)=>axios.post("/educenter/note-list/getNote",fatherid,{
    //请求头参数
    headers: {
        "Content-Type": "application/json"
    }
});
// 新建笔记/文件夹
const addNote = (noteInfo)=>axios.post("/educenter/note-list/addNote",noteInfo);
// 删除笔记/文件夹
const  deleteNote= (noteid)=>axios.post("/educenter/note-list/deleteNote",noteid,{
    // 请求头
    headers: {
      "Content-Type": "application/json",
    }
});
//通过id获取笔记信息
const  getNoteByNoteId= (noteid)=>axios.post("/educenter/note-list/getNoteByNoteId",noteid,{
    // 请求头
    headers: {
      "Content-Type": "application/json",
    }
});
// 更新笔记/文件夹
const updateNote = (noteInfo)=>axios.post("/educenter/note-list/updateNote",noteInfo);
export const http = {getEmailVerify,
    emailLogin,getMemberInfo,
    addNote,getNote,deleteNote,
    getNoteByNoteId,updateNote
};
